/*
 * currency_box.c
 *
 *  Created on: Jan 3, 2009
 *      Author: root
 */
#include <stdlib.h>
#include <gtk/gtk.h>
#include <math.h>

#include "currency_box.h"

typedef struct {
	char *currency;
	char *id;
} CurrencyItem;

CurrencyItem items[] = {
  {"U.S. Do","USD"},
  {"Argenti","ARS"},
  {"Austral","AUD"},
  {"Bahamia","BSD"},
  {"Brazili","BRL"},
  {"Canadia","CAD"},
  {"Chilean","CLP"},
  {"Chinese","CNY"},
  {"Colombi","COP"},
  {"Croatia","HRK"},
  {"Czech. ","CZK"},
  {"Danish ","DKK"},
  {"East Ca","XCD"},
  {"Europea","EUR"},
  {"Fiji Do","FJD"},
  {"African","CFA"},
  {"Pacific","CFP"},
  {"Ghanaia","GHC"},
  {"Guatema","GTQ"},
  {"Hondura","HNL"},
  {"Hong Ko","HKD"},
  {"Hungari","HUF"},
  {"Iceland","ISK"},
  {"Indian ","INR"},
  {"Indones","IDR"},
  {"Israeli","ILS"},
  {"Jamaica","JMD"},
  {"Japanes","JPY"},
  {"Malaysi","MYR"},
  {"Mexican","MXN"},
  {"Morocca","MAD"},
  {"Myanmar","MMK"},
  {"Neth. A","ANG"},
  {"New Zea","NZD"},
  {"Norwegi","NOK"},
  {"Pakista","PKR"},
  {"Panaman","PAB"},
  {"Peruvia","PEN"},
  {"Philipp","PHP"},
  {"Polish ","PLN"},
  {"Russian","RUB"},
  {"Singapo","SGD"},
  {"Slovak ","SKK"},
  {"Sloveni","SIT"},
  {"South A","ZAR"},
  {"South K","KRW"},
  {"Sri Lan","LKR"},
  {"Swedish","SEK"},
  {"Swiss F","CHF"},
  {"Taiwane","TWD"},
  {"Thai Ba","THB"},
  {"Trinida","TTD"},
  {"Tunisia","TND"},
  {"New Tur","TRY"},
  {"Pound S","GBP"},
  {"U.K. Po","GBP"},
  {"Venezue","VEB"},
  {"Vietnam","VND"},
  {NULL, NULL}
};

#define CURRENCY_BOX_GET_PRIVATE(obj)	(G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
										CURRENCY_BOX_TYPE, CurrencyBoxPrivate))
typedef struct _CurrencyBoxPrivate CurrencyBoxPrivate;

struct _CurrencyBoxPrivate {
	GtkComboBox combo;
	gfloat value;
};

//Class initiation
static void
currency_box_class_init (CurrencyBoxClass *klass);
static void
currency_box_init (CurrencyBox *instance);

//Class type
GType
currency_box_get_type (void) {
	static GType entry_type = 0;
	if (!entry_type) {
		static const GTypeInfo entry_info =
		{
			sizeof (CurrencyBoxClass),
			NULL,
			NULL,
			(GClassInitFunc) currency_box_class_init,
			NULL,
			NULL,
			sizeof (CurrencyBox),
			0,
			(GInstanceInitFunc) currency_box_init,
		};
		entry_type = g_type_register_static (GTK_TYPE_VBOX, "CurrencyBox",
												&entry_info, 0);
	}
	return entry_type;
}


//Class properties
enum {
	PROP_VALUE0,
	PROP_VALUE,
	PROP_COMBO,
};

static void
currency_box_get_property (	GObject *gobj,
							guint prop_id,
							GValue *value,
							GParamSpec *pspec) {
	CurrencyBox *myCB = CURRENCY_BOX (gobj);
	CurrencyBoxPrivate *priv = CURRENCY_BOX_GET_PRIVATE (myCB);
	switch (prop_id) {
	case PROP_VALUE:
		g_value_set_float (value, priv->value);
		break;
	case PROP_COMBO:
		break;
	}
};
static void
currency_box_set_property (	GObject *gobj,
							guint prop_id,
							const GValue *value,
							GParamSpec *pspec) {
	CurrencyBox *myCB = CURRENCY_BOX (gobj);
	CurrencyBoxPrivate *priv = CURRENCY_BOX_GET_PRIVATE (myCB);
	switch (prop_id) {
	case PROP_VALUE:
		priv->value = g_value_get_float (value);
		break;
	case PROP_COMBO:
		break;
	}
};

static void
currency_box_class_init (CurrencyBoxClass *klass) {
	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
	//override the standard function to set and retrieve properties
	gobject_class->get_property = currency_box_get_property;
	gobject_class->set_property = currency_box_set_property;

	g_type_class_add_private (klass, sizeof (CurrencyBoxPrivate));
	g_object_class_install_property (gobject_class, PROP_VALUE,
			g_param_spec_float ("value",
								"Value",
								"Money input!",
								0, 100, 0,
								G_PARAM_READWRITE));
	g_object_class_install_property (gobject_class, PROP_COMBO,
			g_param_spec_gtype ("combo",
								"Combo Box",
								"List of nations",
								CURRENCY_BOX_TYPE,
								G_PARAM_READWRITE));
}


static void
currency_box_init (CurrencyBox *instance) {

}

gfloat
currency_box_get_value (CurrencyBox *cb) {
	return 0;
}

GtkWidget *
currency_box_new (){
	return NULL;
}
